<template>
 <div class="profiling_class">
   <div class="card-search cardTop">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="成型" name="profilContent"></el-tab-pane>
      <el-tab-pane label="生产计划" name="productionPlan"></el-tab-pane>
      <el-tab-pane label="报表导出" name="reportExport"></el-tab-pane>
    </el-tabs>
   </div>
   <div class="card-table">
    <profilContent v-if="profilContentif" />
    <productionPlan v-if="productionPlanif" />
    <reportExport v-if="reportExportif" />
   </div>
 </div>
</template>

<script>
// import '@/mock/dataCenter.js'
import profilContent from './tabsProfiling/profilContent.vue'
import productionPlan from './tabsProfiling/productionPlan.vue'
import reportExport from './tabsProfiling/reportExport.vue'

export default {
  name: 'test',
  // mixins: [dataCenter],
  components: {
    profilContent,
    productionPlan,
    reportExport
  },
  data () {
    return {
      activeName: 'profilContent',
      profilContentif: true,
      productionPlanif: false,
      reportExportif: false
    }
  },
  computed: {},
  created () {
    if (sessionStorage.getItem('activeTab')) {
      this.activeName = sessionStorage.getItem('activeTab')
      console.log('this', this.activeName)
      this.profilContentif = false
      this.productionPlanif = false
      this.reportExportif = false
      switch (sessionStorage.getItem('activeTab')) {
        case 'profilContent':
          this.profilContentif = true
          break
        case 'productionPlan':
          this.productionPlanif = true
          break
        case 'reportExport':
          this.reportExportif = true
          break
        default:
          break
      }
    } else {
      sessionStorage.setItem('activeTab', this.activeName)
    }
  },
  beforeRouteLeave (to, from, next) {
    sessionStorage.removeItem('activeTab')
    next()
  },
  mounted () {
  },
  methods: {
    handleClick (tab) {
      // console.log('tab', tab)
      sessionStorage.setItem('activeTab', tab.name)
      this.profilContentif = false
      this.productionPlanif = false
      this.reportExportif = false
      switch (tab.index) {
        case '0':
          this.profilContentif = true
          break
        case '1':
          this.productionPlanif = true
          break
        case '2':
          this.reportExportif = true
          break
        default:
          break
      }
    }
  }
}
</script>

<style  scoped>
.block{
  margin-top: 20px;
  text-align: right;
}
.profiling_class {
  .cardTop {
    padding: 0 18px 0px;
  }
}
</style>
